home *** CD-ROM | disk | FTP | other *** search
- | auto-detaching not baserelative startup code for gcc v2.3.3
- | (c) by M.Fleischer and G.Nikl Sat May 28 11:57 1994
- | No real bugs known but requires v37
-
- | some specific defines
-
- _LVOForbid = -132
- _LVOPermit = -138
- _LVOFindTask = -294
- _LVOGetMsg = -372
- _LVOReplyMsg = -378
- _LVOWaitPort = -384
- _LVOCloseLibrary = -414
- _LVOOpenLibrary = -552
-
- _LVOCreateNewProc = -498
- _LVOCli = -492
-
- pr_MsgPort = 92
- pr_CLI = 172
-
- cli_Module = 60
-
- RETURN_OK = 0
- RETURN_FAIL = 20
-
- | public symbols
-
- .globl ___subexit
- .globl _geta4
-
- .text
-
- | first entry - init some vars, check for cli or wb start
-
- start: movel a0,d3
-
- movel sp,_SaveSP
- movel 4:W,a6
- movel a6,_SysBase
-
- subal a1,a1
- jsr a6@(_LVOFindTask:W)
- movel d0,a3
-
- tstl _DetachFlag
- bnes fromCLI
-
- tstl a3@(pr_CLI:W)
- bne Detach
-
- | wb start - get wbmsg
-
- fromWB: lea a3@(pr_MsgPort:W),a0
- jsr a6@(_LVOWaitPort:W)
- lea a3@(pr_MsgPort:W),a0
- jsr a6@(_LVOGetMsg:W)
- movel d0,__WBenchMsg
-
- | call __submain()
-
- fromCLI: movel d3,___commandline
- jmp ___submain
-
- | __subexit() entry - get return val, restore stackptr
-
- ___subexit: movel __WBenchMsg,d2
- beqs todos
- jsr a6@(_LVOForbid:W)
- movel d2,a1
- jsr a6@(_LVOReplyMsg:W)
-
- todos: movel sp@(4:W),d0
- movel _SaveSP,sp
-
- | geta4() doesn´t do anything, but enables you to use
- | one source for both code models
-
- _geta4: rts
-
- | detach the process from the shell task
-
- NP_Seglist = 0x800003e9
- NP_FreeSeglist = 0x800003ea
- NP_StackSize = 0x800003f3
- NP_Name = 0x800003f4
- NP_Arguments = 0x800003fd
-
- Detach: lea ___dosname,a1
- moveq #37,d0
- jsr a6@(_LVOOpenLibrary:W)
-
- | need a private DOSBase !!!
-
- movel d0,d6
- beq nodos
-
- | get pointer to CommandLineInterface (need not dereference BPTR)
-
- exg d6,a6
- jsr a6@(_LVOCli:W)
- movel d0,a3
- exg d6,a6
-
- | create process with disabled multitasking !!!
-
- jsr a6@(_LVOForbid:W)
-
- | save original stackpointer and setup required taglist
-
- movel sp,a2
- clrl sp@-
- movel d3,sp@-
- pea NP_Arguments
- movel __procname,sp@-
- pea NP_Name
- movel __stack,d0
- beqs defstack
- movel d0,sp@-
- pea NP_StackSize
- defstack: pea 1:W
- pea NP_FreeSeglist
- movel a3@(cli_Module:W),sp@-
- pea NP_Seglist
- movel sp,d1
- exg d6,a6
- jsr a6@(_LVOCreateNewProc:W)
- exg d6,a6
- movel a2,sp
- movel d0,_DetachFlag
- beqs noproc
-
- | clear cli_Module to prevent unloading by the shell
-
- clrl a3@(cli_Module:W)
-
- | reenable multitasking - all done or maybe not ...
-
- noproc: jsr a6@(_LVOPermit:W)
-
- | close dos.library
-
- movel d6,a1
- jsr a6@(_LVOCloseLibrary:W)
-
- | exit graceful
-
- nodos: moveq #RETURN_OK,d0
- rts
-
- | data area
-
- .data
-
- .lcomm _DetachFlag,4
- .comm ___SaveSP,4
- .comm _SysBase,4
- .comm __WBenchMsg,4
- .comm ___commandline,4
-